﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1.IICMoudle
{
    public class I2CConstant
    {
        public static byte REG_IIC_ADDRESS = 0xA0;// public static byte：公开的静态字节类型变量，整个程序中可直接访问，且所有地方引用的是同一个值。
                                                  //REG_IIC_ADDRESS：存储的是目标设备的 I2C 地址
                                                  //重试次数
        public static readonly int REWRITE_TIMES = 3;

        public enum IICSpeed      //I2C 通信速率
        {
            SPEED_20KHZ = 0,  //20KHz 速率，对应值为 0；
            SPEED_100KHZ = 1   //100KHz 速率，对应值为 1。
        }

    }
    public static class ChipMaximConstance
    {
        public enum Reg
        {
            //REG_IIC_ADDRESS = 0xA0,

            REG_FW_VERSION = 0x05,

            REG_DEBUG_MODE_A = 0x80,
            REG_DATA_READY_A = 0x81,
            REG_DEBUG_DATA_A = 0x82,

            REG_DEBUG_MODE_B = 0x80,
            REG_DATA_READY_B = 0x81,
            REG_DEBUG_DATA_B = 0x82,

            REG_DEBUG_MODE_C = 0x83,
            REG_DATA_READY_C = 0x84,
            REG_DEBUG_DATA_C = 0x85,
            REG_DEBUG_MODE_D = 0x86,
            REG_DATA_READY_D = 0x87,
            REG_DEBUG_DATA_D = 0x88,

            REG_MODE_RAWDATA_CRC = 0x10,
            REG_MODE_ADC = 0x08,
        }

        public enum DataReady
        {
            DATA_READY_CLEAR = 0x00
        }
    }
    public static class ChipAwConstance
    {
        public enum Reg
        {
            //REG_IIC_ADDRESS = 0xA0,

            REG_HOST_STATUS = 0x50,

            REG_DEBUG_MODE_A = 0xEC,
            REG_DATA_READY_A = 0xED,
            REG_DEBUG_DATA_A = 0xEE,

            REG_DEBUG_MODE_B = 0xF1,
            REG_DATA_READY_B = 0xF2,
            REG_DEBUG_DATA_B = 0xF3,

            // 校准测试时轮询读数据使用寄存器
            REG_DEBUG_MODE_C = 0xF6,
            REG_DATA_READY_C = 0xF7,
            REG_DEBUG_DATA_C = 0xF8,

            // 低频率使用的单次通信（读写系数、硬件状态等）用寄存器
            REG_DEBUG_MODE_D = 0xFB,
            REG_DATA_READY_D = 0xFC,
            REG_DEBUG_DATA_D = 0xFD,

            // 命令的方式访问寄存器
            REG_HANDSHAKE = 0x01,
            REG_CMD = 0x02,

            REG_FW_VERSION = 0x10,
            REG_MODULE_CONN_STATUS_STATIC = 0x29,
            REG_AFE_GAIN = 0x16,
            REG_OFFSET = 0x17,
            REG_DAC_TO_MV = 0x1C,
            REG_ADC_TO_UV = 0x1B,

            REG_MODULE_CONN_STATUS = 0xA4,

            REG_WRITE_COEFF = 0x30,
            REG_READ_COEFF = 0x31,
        }

        public enum DataReady
        {
            DATA_READY_CLEAR = 0x00
        }
    }

    public static class ChipStConstance
    {
        public enum Reg
        {
            //REG_IIC_ADDRESS = 0x92, // ABOV IIC SLAVE ADDR: 0x20(7bit)

            REG_HOST_STATUS = 0x50,

            REG_DEBUG_MODE_A = 0xEC,
            REG_DATA_READY_A = 0xED,
            REG_DEBUG_DATA_A = 0xEE,

            REG_DEBUG_MODE_B = 0xF1,
            REG_DATA_READY_B = 0xF2,
            REG_DEBUG_DATA_B = 0xF3,

            // 校准测试时轮询读数据使用寄存器
            REG_DEBUG_MODE_C = 0xF6,
            REG_DATA_READY_C = 0xF7,
            REG_DEBUG_DATA_C = 0xF8,

            // 低频率使用的单次通信（读写系数、硬件状态等）用寄存器
            REG_DEBUG_MODE_D = 0xFB,
            REG_DATA_READY_D = 0xFC,
            REG_DEBUG_DATA_D = 0xFD,

            // 命令的方式访问寄存器
            REG_HANDSHAKE = 0x01,
            REG_CMD = 0x02,
            REG_FLASH_FLAG = 0xB5,
            REG_OOR_FLAG = 0xB6,
            REG_GPIO_STATUS = 0x38,
            REG_ADC_2_UVOLT_COEF = 0x1B,

            REG_FW_VERSION = 0x10,
            REG_COUNT_INFO = 0x06,

            // Register Customer Balance
            REG_CUS_BALANCE = 0x23,

            // Reading Customer Balance Coefficient from Flash
            REG_CUS_BALANCE_READ = 0x25,

            // Writing Customer Balance Coefficient to Flash
            REG_CUS_BALANCE_WRITE = 0x26,

            // Register System Balance
            REG_SYS_BALANCE = 0x24,

            // Reading System Balance Coefficient from Flash
            REG_SYS_BALANCE_READ = 0x20,

            // Writing System Balance Coefficient to Flash
            REG_SYS_BALANCE_WRITE = 0x21,

            // Register Button Threshold
            REG_BUTTON_FORCE_THR = 0x5B,

            // Reading Button Threshold from Flash
            REG_BUTTON_FORCE_THR_READ = 0x2A,

            // Writing Button Threshold to Flash
            REG_BUTTON_FORCE_THR_WRITE = 0x2B,

            // Write Scan Rate
            REG_SCAN_RATE = 0x56,

            // write temperature
            REG_TEMPERATURE = 0xBB,
            // read temperature coef
            REG_TEMPERATURE_COEF = 0xBC,

            // remapped ST HW registers to NDT SW registers in the FW,
            // ST HW address format 0xD0 XX 00, for the XX, you can fill in any NDT SW registers address
            REG_ST_ADDRESS_PREFIX = 0xD0,
            REG_ST_ADDRESS_SUFFIX = 0x00,
        }

        public enum Host
        {
            HOST_STATUS_NORMAL = 0x00
        }

        public enum DataReady
        {
            DATA_READY_CLEAR = 0x00
        }

        public enum DebugMode
        {
            // Dynamic Data
            REG_RAW_DATA = 0x10,   // raw * chnum
            REG_FORCE_DATA = 0x20,  // force * chnum
            REG_OPTION_DATA = 0x40,  // raw * chnum + force * chnum + event + total force
            REG_TOTALFORCE_EVENT = 0xC0,  // total force + event
            REG_OTHER_DATA = 0x50,   // base line + adc + ss stable + ff value + cal

            // 特殊的mode，往 Debug_mode 写 mode后，不读 Debug_ready 有没有准备好数据，直接从 Debug_data 取数据
            REG_MODE_OPTION_DATA = 0xC1,

            // 特殊模式，往 Debug_mode 写 mode后，不读 Debug_ready 有没有准备好数据,直接读寄存器值
            REG_MODE_F3 = 0xF3,

            DEBUG_MODE_ALLDATA = 0xF4,
            DEBUG_MODE_OFF = 0x00,

            DEBUG_MODE_WRITECOEFF = 0x30,
            DEBUG_MODE_READCOEFF = 0x31,
        }
    }
    public static class ChipSeaConstance
    {
        public enum Reg
        {
            //REG_IIC_ADDRESS = 0xA0,

            REG_HOST_STATUS = 0x50,

            REG_DEBUG_MODE_A = 0xEC,
            REG_DATA_READY_A = 0xED,
            REG_DEBUG_DATA_A = 0xEE,

            REG_DEBUG_MODE_B = 0xF1,
            REG_DATA_READY_B = 0xF2,
            REG_DEBUG_DATA_B = 0xF3,

            // 校准测试时轮询读数据使用寄存器
            REG_DEBUG_MODE_C = 0xF6,
            REG_DATA_READY_C = 0xF7,
            REG_DEBUG_DATA_C = 0xF8,

            // 低频率使用的单次通信（读写系数、硬件状态等）用寄存器
            REG_DEBUG_MODE_D = 0xFB,
            REG_DATA_READY_D = 0xFC,
            REG_DEBUG_DATA_D = 0xFD,

            // 命令的方式访问寄存器
            REG_HANDSHAKE = 0x01,
            REG_CMD = 0x02,

            REG_FW_VERSION = 0x10,
            REG_MODULE_CONN_STATUS_STATIC = 0x29,
            REG_AFE_GAIN = 0x16,
            REG_OFFSET = 0x17,
            REG_DAC_TO_MV = 0x1C,
            REG_ADC_TO_UV = 0x1B,

            REG_MODULE_CONN_STATUS = 0xA4,

            REG_WRITE_COEFF = 0x30,
            REG_READ_COEFF = 0x31,
        }

        public enum DataReady
        {
            DATA_READY_CLEAR = 0x00
        }
    }

}
